<template>
  <div tabindex="0" class="input" @click.stop.prevent="inputfoucs" @keydown="inputkeydown">{{value}}</div>
</template>

<script>
export default {
  name: 'div2input',
  props:['value'],
  mounted(){
    this.$props
    console.log(this.$props)
  },
  methods:{
    inputfoucs(e){
      e.target.focus()
    },
    inputkeydown(e){
      console.log(e);
      let text=this.value
      if(e.key==='Backspace'){
        this.$emit('input',text.slice(0,text.length-1))
      }else if(e.key==='Enter'){
        this.$emit('input',text.slice(0,text.length-1))
      }else{
        this.$emit('input',e.target.innerText+e.key)
      }
    }
  }
}
</script>
<style scoped>
.input{
  max-width: 200px;
  min-height: 100px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #000;
  border-radius: 5px;
  background-color: #fff;
  margin: 10px;
  cursor: pointer;
}
</style>
